#!/usr/bin/env perl

use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/gen-perl/";

use lib './gen-perl';
use Thrift;
use Thrift::BinaryProtocol;
use Thrift::BufferedTransport;
use Thrift::Socket;
use Throomie;

my $transport = Thrift::Socket->new('localhost', 9090);
my $client = ThroomieClient->new( Thrift::BinaryProtocol->new(Thrift::BufferedTransport->new($transport)) );
$transport->open();
$client->beginClassification();

my $cnt = 1;
while(my $line = <>){
    chomp $line;
    my @elements = split "\t", $line;
    my $seikai = shift @elements;
    unshift @elements, $cnt;
    my $input = join "\t", @elements;
    my $rv = $client->classify($input);
    print "$rv\n\n";
    $cnt++;
}

$client->endClassification();
$transport->close();
